﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

<div class="row">
    <label>账号</label>
    <input type="text" class="form-control" id="txtAccount" />
</div>
<div class="row">
    <label>密码</label>
    <input type="password" class="form-control" id="txtPassword" />
</div>
<div class="row">
    <button class="btn btn-primary" id="btnLogin"> 登录</button>
</div>
<script>
    localStorage.removeItem("mytoken");
    $("#btnLogin").click(function(){
        var account=$("#txtAccount").val();
        var pasword=$("#txtPassword").val();
        $.ajax({
            url:"/home/DoLogin?account="+account+"&password="+pasword,
            type:"POST",
            success:function(d){
                if(d.code==1){
                    localStorage.setItem("mytoken",d.token);
                    alert("登录成功");
                    location.href="/home/index";
                }
                else{
                    alert("登录失败");
                }
            }
        });
    });
</script>
